home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13578 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: herold.franken.de!jhd
  2. Date: 23 Mar 1996 14:27:00 +0100
  3. From: jhd@herold.franken.de (Joachim Durchholz)
  4. Newsgroups: comp.lang.eiffel,comp.lang.c,comp.lang.c++,comp.object,comp.software-eng
  5. Message-ID: <65O34-3-3RB@herold.franken.de>
  6. References: <31494D29.4D4B@dmu.ac.uk> <DoG3HE.48E@assip.csasyd.oz>
  7.     <31517E6F.5930@dmu.ac.uk> <DooBwC.8C0@world.std.com>
  8. Subject: Re: Portability of code & skills (Beware of "C" Hackers etc)
  9. X-Newsreader: CrossPoint v3.1
  10.  
  11. tej@world.std.com wrote 22.03.96 on Re: Portability of code & skills (Beware of "C" Hackers etc):
  12.  
  13. > I don't remember enough Pascal to know what you mean.  I know you could
  14. > define a function inside a function, making Pascal block-structured.
  15. > C can't do that, but of course you can pass functions as arguments of
  16. > functions.
  17.  
  18. The power of this mechanism is that the local function can access local  
  19. variables of its surrounding function. E.g. in a list processing  
  20. environment you could write
  21.  
  22.   function CountThem (l: List): integer;
  23.   var Count: integer
  24.     procedure CountOne (e: ListElement);
  25.     begin
  26.       if <some condition on e fulfilled> then begin
  27.         Count := Count + 1;
  28.       end;
  29.     end;
  30.   begin
  31.     ApplyOnList (l, CountOne); (* !!!! *)
  32.     CountThem := Count
  33.   end;
  34.  
  35.  
  36. > >No assertions
  37. > I know it's dumb but what's wrong with assert() from assert.h?
  38. Nothing wrong, but there are better frameworks. See programming-by- 
  39. contract (e.g. in Bertrand Meyer, Object-Oriented Software Construction,  
  40. Prentice Hall).
  41.  
  42. > >No opaque types
  43. > a pointer to an empty struct declaration works fine.
  44. The compiler cannot warn you if you inadvertently mix types.
  45.  
  46. > If you're going to compare Ada 95 to C '72, what's the point?
  47. Agreed.
  48.  
  49.  
  50. -Joachim
  51.  
  52. --
  53. Im speaking for myself here.
  54. ## CrossPoint v3.1 ##
  55.